﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevComponents.DotNetBar;

namespace SharpErp.UI.Common
{
    public class BaseDialogForm : RibbonForm 
    {
    	protected SharpErp.Data.Service.ISharpErpService Service{get{return SharpErp.Service.Client.ServiceWarpper.GetService();}}

        protected event EventHandler BeforeLoad;

        protected event EventHandler AfterLoad;

        protected override void OnLoad(EventArgs e)
        {
            try
            {
            	if(BeforeLoad != null)BeforeLoad.Invoke(this, e);
            }
            catch (Exception ex)
            {
                SharpErp.Common.Util.Logger.GetLog().Error("BaseTabForm.BeforeLoad", ex);
            }
            base.OnLoad(e);
            try
            {
            	if(AfterLoad != null) AfterLoad.Invoke(this, e);
            }
            catch (Exception ex)
            {
                SharpErp.Common.Util.Logger.GetLog().Error("BaseTabForm.AfterLoad", ex);
            }

        }

        protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
		{
			if(keyData == System.Windows.Forms.Keys.Escape){
				Close();
				return true;
			}
			return base.ProcessCmdKey(ref msg, keyData);
		}
    }
}
